package com.ljx.itbbs.server.user.dao;

import com.ljx.itbbs.server.user.domain.vo.req.RoleUpdateReq;
import com.ljx.itbbs.server.user.mapper.RoleMapper;
import com.ljx.itbbs.server.user.domain.entity.RoleEntity;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 角色表 服务实现类
 * </p>
 *
 * @author LiJunXi
 * @since 2024-03-02
 */
@Service
public class RoleDao extends ServiceImpl<RoleMapper, RoleEntity> {

    public List<RoleEntity> getByUId(Long userId) {
        return this.baseMapper.getByUId(userId);
    }

    public void updateRoleInfo(RoleUpdateReq req) {
        lambdaUpdate().set(RoleEntity::getName, req.getName())
                .set(RoleEntity::getRoleValue, req.getRoleValue())
                .set(RoleEntity::getStatus, req.getStatus())
                .eq(RoleEntity::getId, req.getId())
                .update();
    }
}
